home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus Special 16 / AMIGAplus Sonderheft 16 (1998)(ICP)(DE)[!].iso / pd / anwendungen / rtgmaster_dev / devdocs / skeleton.asm < prev    next >
Assembly Source File  |  1997-09-26  |  11KB  |  414 lines

  1. ; This is a code skeleton for a sublibrary for the
  2. ; rtgmaster.library ... no guarantie that it is bugfree :)
  3. ; I extracted it out of an existing library source of
  4. ; mine ... Sometimes you will have toi exchange CGX
  5. ; by the name of YOUR sublibrary in this code !!!
  6. ; Also, this code may be incomplete...
  7.  
  8. ; Code provided by you HAS to be 100% in Assembly language.
  9. ; You will have to write all needed include files, too...
  10. ; (look at the include files of the other sublibs for
  11. ; examples and for learning what structures exist...
  12. ; study the autodocs, too...)
  13. ; so the files that have to be done by you to do a sublibrary
  14. ; for the XYZ-GFX Board would be (note, that the short name
  15. ; for the Board has to be three letters + blank or four letters) :
  16. ; rtgXYZ.i
  17. ; rtgXYZ.h
  18. ; rtgXYZ.library.asm
  19. ; rtgXYZ.library
  20.  
  21.  
  22. LibVersion      EQU     2
  23. LibRevision     EQU     0
  24.  
  25. ; Look at rtgmaster.guide to get explained which version number has to
  26. ; feature which functions
  27.  
  28. LibName MACRO
  29.         Dc.b    "rtgXYZ"
  30.  
  31.         ; INSERT LIBNAME HERE !!!
  32.         ; LIBNAME HAS TO BE rtg and UP TO
  33.         ; FOUR LETTERS !!! (or three letters + Blank)
  34.  
  35.         ENDM
  36.  
  37. LibVersion      MACRO
  38.         Dc.b    "2"
  39.         Dc.b    ".","0"
  40.         ENDM
  41.  
  42. ; Look at rtgmaster.guide to get the version numbers explained...
  43.  
  44. XYZ_ID  EQU     "XYZ "
  45.  
  46.         ; PUT HERE THE NAME OF THE LIB WITHPOUT rtg
  47.         ; AND FILL IN BLANKS, IF NEEDED...
  48.  
  49.         incdir  "INCLUDE:"
  50.  
  51.         include "exec/initializers.i"
  52.         include "exec/libraries.i"
  53.         include "exec/types.i"
  54.         include "exec/funcdef.i"
  55.         include "exec/memory.i"
  56.         include "utility/tagitem.i"
  57.         include "rtgmaster/rtgsublibs.i"
  58.         include "rtgmaster/rtgmaster.i"
  59.         include "rtgmaster/rtgXYZ.i"
  60.         include "cybergraphics/cybergraphics.i"
  61.         include "intuition/screens.i"
  62.         include "include:utility/utility_lib.i"
  63.  
  64. ; INCLUDES AND DEFINES HERE...
  65.  
  66. _LVOAllocMem EQU -198
  67. _LVOFreeMem EQU -210
  68.  
  69. LibraryExecuteCode      Moveq   #0,d0
  70.         Rts
  71.  
  72.         CNOP    0,4
  73.  
  74. rt_MatchTag     Dc.w    $4afc
  75. rt_ROMTag       Dc.l    rt_MatchTag
  76. rt_EndSkip      Dc.l    lib_EndCode
  77. rt_Flags        Dc.b    128     ; RTG_AUTOINIT
  78. rt_Version      Dc.b    LibVersion
  79. rt_Type Dc.b    NT_LIBRARY
  80. rt_Pri  Dc.b    0
  81. rt_Name Dc.l    Text_Library
  82. rt_IDString     Dc.l    Text_Library_ID
  83. rt_Init Dc.l    InitTable
  84.  
  85. Text_Library    LibName
  86.         Dc.b    ".library",0
  87.  
  88. Text_Library_ID LibName
  89.         Dc.b    " "
  90.         LibVersion
  91.         Dc.b    " (16.2.95)",10,0
  92.         Dc.b    "Created by Steffen Häuser",10,0
  93.  
  94. ; Put here your copyright...
  95.  
  96.         CNOP    0,4
  97.  
  98. InitTable       Dc.l    rbXYZ_SIZEOF
  99.  
  100. ; HERE rbXYZ_SIZEOF with appropriate name has to be
  101. ; put in...
  102.  
  103.         Dc.l    FunctionTable
  104.         Dc.l    DataTable       ;something like primary init
  105.         Dc.l    InitRtgLibrary
  106.  
  107.  
  108. FunctionTable   ;OS functions
  109.         Dc.l    lib.Open
  110.         Dc.l    lib.Close
  111.         Dc.l    lib.ExpungeLib
  112.         Dc.l    lib.ExtFunc
  113.  
  114.         ;public functions
  115.         ; *************************************************
  116.         ; ** Don't change the order of these function !! **
  117.         ; *************************************************
  118.         ;
  119.         Dc.l    _OpenRtgScreen
  120.         Dc.l    _CloseRtgScreen
  121.         Dc.l    _GetRtgScreenData
  122.         Dc.l    _GetScreenModes
  123.         Dc.l    _FreeScreenModes
  124.         Dc.l    _LockRtgScreen
  125.         Dc.l    _UnlockRtgScreen
  126.         Dc.l    _GetBufAdr
  127.         Dc.l    _GetSegment
  128.         Dc.l    _SetSegment
  129.         Dc.l    _LoadRGBRtg
  130.         Dc.l    _RtgScreenAtFront
  131.         Dc.l    _SwitchScreens
  132.         Dc.l    _WriteRtgPixel
  133.         Dc.l    _WriteRtgPixelRGB
  134.         Dc.l    _FillRtgRect
  135.         Dc.l    _FillRtgRectRGB
  136.         Dc.l    _WriteRtgPixelArray
  137.         Dc.l    _WriteRtgPixelRGBArray
  138.         dc.l    _CopyRtgPixelArray
  139.         dc.l    _CopyRtgBlit
  140.         dc.l    _DrawRtgLine
  141.         dc.l    _DrawRtgLineRGB
  142.         dc.l    _WaitRtgSwitch
  143.         dc.l    _WaitRtgBlit
  144.         dc.l    _RtgWaitTOF
  145.         dc.l    _RtgBlit
  146.         dc.l    _RtgBltClear
  147.         dc.l    _CallRtgC2P
  148.         dc.l    _RtgText
  149.         dc.l    _RtgSetFont
  150.         dc.l    _RtgClearPointer
  151.         dc.l    _RtgSetPointer
  152.         dc.l    _RtgSetTextMode
  153.         dc.l    _RtgOpenFont
  154.         dc.l    _RtgCloseFont
  155.         dc.l    _RtgSetTextModeRGB
  156.         dc.l    _RtgInitRDCMP
  157.         dc.l    _RtgWaitRDCMP
  158.         dc.l    _RtgGetMsg
  159.         dc.l    _RtgReplyMsg
  160.         dc.l    _RtgCheckVSync
  161.         Dc.l    -1
  162.  
  163. DataTable       INITBYTE        LN_TYPE,NT_LIBRARY
  164.         INITLONG        LN_NAME,Text_Library
  165.  
  166.         INITBYTE        LIB_FLAGS,LIBF_CHANGED|LIBF_SUMUSED
  167.         ;something has changed the library since last sum;
  168.         ;indicates if the library allows checksumming
  169.  
  170.         INITWORD        LIB_VERSION,LibVersion
  171.         INITWORD        LIB_REVISION,LibRevision
  172.         INITLONG        LIB_IDSTRING,Text_Library_ID
  173.         dc.l    0
  174.  
  175.  
  176.  
  177. lib.Open        ; IN: d0 = version
  178.         ; IN: a6 = *library base
  179.         ;OUT: d0 = *library base, if successful, 0 otherwise
  180.  
  181.         Addq.w  #1,LIB_OPENCNT(a6)
  182.         Bclr    #LIBB_DELEXP,LIB_FLAGS(a6)
  183.  
  184.         Move.l  a6,d0
  185.         Rts
  186.  
  187. lib.Close       ; IN: a6 = *library base
  188.         ;OUT: d0 = *SegList, if no longer open and delayed expunge,
  189.         ;          0 otherwise
  190.  
  191.         Moveq   #0,d0
  192.  
  193.         Subq.w  #1,LIB_OPENCNT(a6)
  194.         Bne.s   .OpenCountNot0
  195.  
  196.         Btst    #LIBB_DELEXP,LIB_FLAGS(a6)
  197.         Beq.s   .DontExpungeLibrary
  198.  
  199.         Bsr.s   lib.ExpungeLib
  200.  
  201. .OpenCountNot0
  202. .DontExpungeLibrary     Rts
  203.  
  204.  
  205.  
  206.  
  207. lib.ExpungeLib
  208.  
  209. ;according  to Autodocs/RemLibrary a Forbid/Permit pair MUST be placed around
  210. ;RemLibrary  to  be  secure.  This should be granted, for ROM code calls this
  211. ;typically.  If not called from ROM, there MUST be Forbid/Permit.
  212.  
  213.         ; IN: a6 = *library base
  214.         ;OUT: d0 = *SegList, if no longer open and delayed expunge,
  215.         ;          0 otherwise
  216.  
  217.         Tst.w   LIB_OPENCNT(a6)
  218.         Bne.s   .OpenCountNot0
  219.  
  220. ;free   all   resources  (fi  close  libraries)  here  that  were  opened  in
  221. ;Init_xpkHUFFLibrary
  222.  
  223. ;xpkHUFF_EL_RemoveLibraryNode:
  224.  
  225.         Movem.l d1-d7/a0-a6,-(sp)
  226.  
  227.         Move.l  a6,a5
  228.  
  229.         Bsr     SmartFree
  230.  
  231.         Move.l  a6,a5
  232.  
  233.         Move.l  a6,a1
  234.         Move.l  4.w,a6
  235.         Jsr     -252(a6)
  236.  
  237.         Move.l  rbXYZ_SegList(a5),d7
  238.  
  239.         ; THE SEGLIST !!!
  240.  
  241.         Move.l  a5,a1   *xpkHUFF library base
  242.         Moveq   #0,d0
  243.         Move.w  LIB_NEGSIZE(a5),d0
  244.         Sub.l   d0,a1   equ *memory to free
  245.         Add.w   LIB_POSSIZE(a5),d0      equ size of memory to free
  246.  
  247.         Move.l  4.w,a6
  248.         Jsr     -198(a6)
  249.  
  250.         Move.l  d7,d0   return SegList
  251.  
  252.         Movem.l (sp)+,d1-d7/a0-a6
  253.         Rts
  254.  
  255.  
  256. .OpenCountNot0  Bset    #LIBB_DELEXP,LIB_FLAGS(a6)      ;next CloseLib will expunge
  257.                         ;the library if OpenCount = 0
  258.         Moveq   #0,d0
  259.         Rts
  260.  
  261.  
  262. lib.ExtFunc     Moveq   #0,d0
  263.         Rts
  264.  
  265. InitRtgLibrary
  266.  
  267.  ; IN: d0 = *library base
  268.         ; IN: a0 = *segment list
  269.         ; IN: a6 = *execbase
  270.         ;OUT: d0 = *librarybase, if succesfull, 0 otherwise
  271.  
  272.         Movem.l a0-a1/d0-d1/d6/a5,-(sp)
  273.  
  274.         Move.l  d0,a5
  275.         Move.l  a0,rbXYZ_SegList(a5)
  276.  
  277.         Move.l  a6,rbXYZ_ExecBase(a5)
  278.  
  279.         ; Insert XYZ...
  280.  
  281.         ; PUT LIBRARY INIT CODE HERE... especially
  282.         ; open all needed libraries...
  283.  
  284.         Move.l  a5,d0
  285.         Bra.s   .Ok
  286.  
  287.         ; You should only jump to .Ok if the graphics
  288.         ; board intended for the use of this sublibrary
  289.         ; was FOUND (you have to provide some code for
  290.         ; this), if this is possible for the Board...
  291.         ; Do not only check for the libraries being
  292.         ; installed, check for Screenmodes or Board
  293.         ; Drivers... (if possible...) If no board was
  294.         found, jump to .Error
  295.  
  296. .Ok     Movem.l (sp)+,a0-a1/d0-d1/d6/a5
  297.         Rts
  298. .Error  movem.l (sp)+,a0-a1/d0-d1/d6/a5
  299.         move.l #0,d0
  300.         rts
  301.  
  302. SmartFree
  303.  
  304.         ; Close the Libraries again here...
  305.         ; if they are not already close... will
  306.         ; be used in errorcase, too...
  307.  
  308.  
  309.  
  310. ; And now include all the functions HERE... you should
  311. ; at LEAST support all V1.0 functions... you do not need
  312. ; to support 2.0 functions up to now, if you have not
  313. ; the time to implement all this stuff... As far as i got
  314. ; it from John Hendrikx, rtgmaster.library does not support
  315. ; all rtg 2.0 functions anyways, up to now ...
  316.  
  317. _GetScreenmodes
  318.  
  319. ; IN: a6.l = rtgXYZ.library base
  320.         ;OUT: d0.l = List of ScreenModes or zero
  321.         ;COM: you may destroy d0-d1,a0-a1
  322.  
  323. ; This function will be called by rtgmaster.library
  324. ; and will return a list of Screenmodes available on
  325. ; this Board. Be sure it returns 0, if the Board is not
  326. ; available, and that it does not return Screenmodes
  327. ; that do not belong to the Board... You will have
  328. ; to save the Screenmodes in the RTGScreenmode format
  329. ; that is described in the Includes... you will also
  330. ; have to write a rtgXXX.h and a rtgXXX.i file, look
  331. ; at the includes for examples... Stuff in these two
  332. ; files is considered private for your sublibrary...
  333. ; If it happens, that your board has a Video RAM organisation
  334. ; that currently is not supported by rtgsublibs.i,
  335. ; please inform me, so that i can
  336. ; modify the Include file...
  337.  
  338. _FreeScreenModes        ; IN: a0.l = List of ScreenModes or zero
  339.         ; IN: a6.l = rtgCGX.library base
  340.         ;COM: you may destroy d0-d1,a0-a1
  341.  
  342. ; Free the Screenmodelist again...
  343.  
  344. Insert the functions HERE :
  345.  
  346. _OpenRtgScreen:
  347. _CloseRtgScreen:
  348. _GetRtgScreenData:
  349. _LockRtgScreen:
  350. _UnlockRtgScreen:
  351. _GetBufAdr:
  352. _LoadRGBRtg:
  353. _RtgScreenAtFront:
  354. _SwitchScreens:
  355. _WriteRtgPixel:
  356. _WriteRtgPixelRGB:
  357. _FillRtgRect:
  358. _FillRtgRectRGB:
  359. _WriteRtgPixelArray:
  360. _WriteRtgPixelRGBArray:
  361. _CopyRtgPixelArray:
  362. _DrawRtgLine:
  363. _DrawRtgLineRGB:
  364. _WaitRtgSwitch:
  365. _WaitRtgBlit:
  366. _RtgWaitTOF:
  367. _RtgBlit:
  368. _RtgBltClear:
  369. _CallRtgC2P:
  370. _RtgText:
  371. _RtgSetFont:
  372. _RtgClearPointer:
  373. _RtgSetPointer:
  374. _RtgSetTextMode:
  375. _RtgOpenFont:
  376. _RtgCloseFont:
  377. _RtgSetTextModeRGB:
  378. _RtgInitRDCMP
  379. _RtgWaitRDCMP
  380. _RtgGetMsg
  381. _RtgReplyMsg
  382. _CopyRtgBlit
  383. _RtgCheckVSync
  384.  
  385. ; Some last notes :
  386. ; 1. For the blitting functions use the GFX Board Blitter
  387. ; 2. If the Board can't do the blitting functions without
  388. ;    waiting on the Blitter, well, then do them WITH waiting
  389. ;    and let WaitRtgBlit do simply nothing
  390. ; 3. CopyRtgPixelArray and CallRtgC2P have to be implemented
  391. ;    in a way that they directly access the Video RAM. *NO*
  392. ;    OS functions allowed !!!
  393. ; 4. For the Write...Pixel... functions OS functions are
  394. ;    allowed... those color conversion stuff with the RGB ones
  395. ;    is slow anyways...
  396. ; 5. The Draw and Fill Functions have to use the GFX Board
  397. ;    blitter if this is possible
  398. ; 6. If the board does not need segmented memory, GetSegment
  399. ;    and SetSegment simply do nothing (GetSegment returns 0
  400. ;    in this case)
  401. ; 7. Your code should be 68020-optimized.
  402. ; 8. If some functions are NOT possible to be implemented on
  403. ;    your board (like for example Pointer stuff for Picasso
  404. ;    WB Emulation), simply let the functions do NOTHING. Do
  405. ;    NOT simply leave them out, else applications that  use
  406. ;    them might crash. Also, send me a note about the fact,
  407. ;    that certain functions can't be supported, and i will add
  408. ;    something to the docs+autodocs
  409. ; 9. GetSegment/SetSegment were removed. They only remain
  410. ;    in the code, so that the offsets do not change. But you
  411. ;    can implement them as empty functions.
  412.  
  413.         END
  414.